home *** CD-ROM | disk | FTP | other *** search
- Path: news.larc.nasa.gov!amiga-request
- From: amiga-request@ab20.larc.nasa.gov (Amiga Sources/Binaries Moderator)
- Subject: v91i059: Bytes 1.10 - display number of free bytes on selected drive, Part01/01
- Reply-To: d0pbm@dtek.chalmers.se (Per Bergehed)
- Newsgroups: comp.sources.amiga
- Message-ID: <comp.sources.amiga:v91i059@ab20.larc.nasa.gov>
- Date: 14 Mar 91 01:17:25 GMT
- Approved: tadguy@uunet.UU.NET (Tad Guy)
- X-Mail-Submissions-To: amiga@uunet.uu.net
- X-Post-Discussions-To: comp.sys.amiga.misc
-
- Submitted-by: d0pbm@dtek.chalmers.se (Per Bergehed)
- Posting-number: Volume 91, Issue 059
- Archive-name: utilities/bytes-1.10/part01
-
- This program will display the number of free bytes on selected drive:
-
- Syntax: Bytes [DRIVE:]
-
-
- #!/bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of archive 1 (of 1)."
- # Contents: bytes.c
- # Wrapped by tadguy@ab20 on Wed Mar 13 20:17:23 1991
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'bytes.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'bytes.c'\"
- else
- echo shar: Extracting \"'bytes.c'\" \(3040 characters\)
- sed "s/^X//" >'bytes.c' <<'END_OF_FILE'
- X/*-------------------------------------------------------------------------*/
- X/* Bytes v1.10 Released to the Public Domain 1991.01.04 /PBM/ Per Bergehed */
- X/*-------------------------------------------------------------------------*/
- X/* s-nail: Per Bergehed * This code is not a "good" example of */
- X/* Richertsgatan 2C/3003 * C Programming, but hopefully there */
- X/* 412 81 Gothenburg * is something usable !? */
- X/* SWEDEN * There shouldn't be any problems if */
- X/* e-mail: d0pbm@dtek.chalmers.se * you want to modify it to not use ARP */
- X/*-------------------------------------------------------------------------*/
- X/*
- X This program will display the number of free bytes on selected drive:
- X
- X Syntax: Bytes [DRIVE:]
- X*/
- X/*-------------------------------------------------------------------------*/
- X/*
- X I compiled this source with Lattice C as follows:
- X
- X LC -v Bytes.c
- X BLINK LIB:arpc.o RAM:bytes.o TO RAM:Bytes LIB lib:arp.lib,lib:amiga.lib,lib:lc.lib SD SC ND
- X
- X*/
- X/*-------------------------------------------------------------------------*/
- X
- X#include <exec/types.h>
- X#include <stdlib.h>
- X#include <string.h>
- X#include <dos.h>
- X#include <libraries/arpbase.h>
- X#include <libraries/arp_pragmas.h>
- X#include <arpfunctions.h>
- X
- X
- X
- X#define Kb 1024L
- X#define Mb (Kb*Kb)
- X
- X
- X
- Xchkabort (void) {} /* dummy to get rid of chkabort() */
- X
- X
- X
- Xstruct DISKINFO info;
- X
- X
- X
- Xvoid _main(argv)
- Xregister char *argv;
- X{
- X register char MyPath[255];
- X register char *myptr = MyPath;
- X
- X while (*argv != ' ')
- X argv++;
- X while (*argv == ' ')
- X argv++; /* argv now points to command line argument */
- X
- X if ( *argv == '\x0a' ) /* no argument -> get current directory */
- X {
- X if (getcd(0,MyPath)) goto error; /* getcd() - AMIGA function */
- X }
- X else /* get argument */
- X {
- X while (*argv != '\x0a')
- X {
- X *myptr = *argv;
- X myptr++;
- X argv++;
- X }
- X myptr = MyPath;
- X }
- X
- X if (!getdfs (myptr,&info)) /* getdfs() - AMIGA function */
- X {
- X register long bytes = (long) (info.id_NumBlocks - info.id_NumBlocksUsed) * info.id_BytesPerBlock;
- X
- X Printf("%s ",myptr);
- X
- X if (bytes > Mb)
- X {
- X register long Mbytes = bytes / Mb;
- X register long Kbytes = (bytes % Mb) / 100000;
- X Printf("%ld.%ld Mb",Mbytes,Kbytes);
- X }
- X else Printf("%ld bytes",bytes);
- X
- X Printf(" free.\n");
- X return; /* normal exit */
- X }
- X
- Xerror:
- X
- X Printf("\n\2331;33m Bytes\2330m\2331;31m Version 1.10 Public Domain 1990 /PBM/ Per Bergehed.\2330m\n");
- X Printf(" - to contact me send e-mail to: d0pbm@dtek.chalmers.se -\n");
- X Printf("\n Syntax:\2331;33m Bytes\2330m [DRIVE:]\n\n");
- X
- Xreturn; /* error exit! */
- X}
- X//*-------------------------------------------------------------------------*/
- X
- X
- X
- END_OF_FILE
- if test 3040 -ne `wc -c <'bytes.c'`; then
- echo shar: \"'bytes.c'\" unpacked with wrong size!
- fi
- # end of 'bytes.c'
- fi
- echo shar: End of archive 1 \(of 1\).
- cp /dev/null ark1isdone
- MISSING=""
- for I in 1 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have the archive.
- rm -f ark[1-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
- --
- Mail submissions (sources or binaries) to <amiga@uunet.uu.net>.
- Mail comments to the moderator at <amiga-request@uunet.uu.net>.
- Post requests for sources, and general discussion to comp.sys.amiga.misc.
-